package com.ssy.lingxi.settle.accounts.entity;

import com.ssy.lingxi.settle.accounts.handler.converter.JpaJsonToPayProveBOConverter;
import com.ssy.lingxi.settle.accounts.handler.converter.JpaJsonToSettlementOrderBOConverter;
import com.ssy.lingxi.settle.accounts.model.bo.PayProveBO;
import com.ssy.lingxi.settle.accounts.model.bo.SettlementOrderBO;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 会员结算DO
 * 付钱会员配置规则，收钱会员等同于结算方
 * @author 伍将
 * @date 2020/10/23
 * @version 2.0.0
 */
@Entity
@Table(schema = "public", name = "sa_member_settlement",
        indexes = {@Index(name = "sa_member_settlement_member_idx", columnList = "memberId,roleId"),
                @Index(name = "sa_member_settlement_pay_member_idx", columnList = "payMemberId,payRoleId"),
                @Index(name = "sa_member_settlement_settlement_date_idx", columnList = "settlementDate"),
                @Index(name = "sa_member_settlement_settlement_way_idx", columnList = "settlementWay"),
                @Index(name = "sa_member_settlement_order_type_idx", columnList = "orderType"),
                @Index(name = "sa_member_settlement_status_idx", columnList = "status")})
public class MemberSettlementDO implements Serializable {
    private static final long serialVersionUID = 1883905376306395728L;

    /**
     * ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "member_settlement_seq")
    @SequenceGenerator(sequenceName = "sa_member_settlement_seq", name = "member_settlement_seq", allocationSize = 1)
    private Long id;

    /**
     * 结算会员id
     */
    @Column(columnDefinition = "int8")
    private Long memberId;

    /**
     * 结算角色id
     */
    @Column(columnDefinition = "int8")
    private Long roleId;

    /**
     * 结算方
     */
    @Column(columnDefinition = "varchar(50)")
    private String settlementName;

    /**
     * 付款会员id
     */
    @Column(columnDefinition = "int8")
    private Long payMemberId;

    /**
     * 付款角色id
     */
    @Column(columnDefinition = "int8")
    private Long payRoleId;

    /**
     * 支付方
     */
    @Column(columnDefinition = "varchar(50)")
    private String payName;

    /**
     * 结算单号
     */
    @Column(columnDefinition = "varchar(20)")
    private String settlementNo;

    /**
     * 结算方式:1.账期 2.月结
     * 定义：SettlementWayEnum
     */
    @Column(columnDefinition = "int")
    private Integer settlementWay;

    /**
     * 结算单据类型:1.生成通知单 2.物流单 3.订单 4.积分订单 5.退货申请单 6.请款单
     * 来源枚举：SettlementOrderTypeEnum
     */
    @Column(columnDefinition = "int")
    private Integer orderType;

    /**
     * 开始时间
     */
    @Column(columnDefinition = "int8")
    private Long startTime;

    /**
     * 结束时间
     */
    @Column(columnDefinition = "int8")
    private Long endTime;

    /**
     * 总单数
     */
    @Column(columnDefinition = "int")
    private Long totalCount;

    /**
     * 结算金额
     */
    @Column(columnDefinition = "decimal")
    private Double amount;

    /**
     * 结算日期
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long settlementDate;

    /**
     * 结算时间
     */
    @Column(columnDefinition = "int8")
    private Long settlementTime;

    /**
     * 预付款时间
     */
    @Column(columnDefinition = "int8")
    private Long prePayTime;

    /**
     * 实际付款时间
     */
    @Column(columnDefinition = "int8")
    private Long payTime;

    /**
     * 结算状态：0-所有，1-待对账，2-待付款，3-待收款，4-已完成
     * 来源枚举：SettlementStatusEnum
     */
    @Column(columnDefinition = "int")
    private Integer status;

    /**
     * 支付方式：1.线上支付 2.线下 3.授信 4.货到付款
     */
    @Column(columnDefinition = "int")
    private Integer payWay;

    /**
     * 策略id
     * 值为0是请款生成的
     */
    @Column(columnDefinition = "int8")
    private Long strategyId;

    /**
     * 支付证明
     */
    @Convert(converter = JpaJsonToPayProveBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<PayProveBO> payProveList;

    /**
     * 更新时间
     */
    @Column(columnDefinition = "int8")
    private Long updateTime;

    /**
     * 结算单据信息
     */
    @Convert(converter = JpaJsonToSettlementOrderBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private SettlementOrderBO orderBO;

    /**
     * 在线支付的商户订单号，用于退款
     */
    @Column(columnDefinition = "varchar(50)")
    private String tradeNo;

    public SettlementOrderBO getOrderBO() {
        return orderBO;
    }

    public void setOrderBO(SettlementOrderBO orderBO) {
        this.orderBO = orderBO;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public String getSettlementName() {
        return settlementName;
    }

    public void setSettlementName(String settlementName) {
        this.settlementName = settlementName;
    }

    public String getPayName() {
        return payName;
    }

    public void setPayName(String payName) {
        this.payName = payName;
    }

    public List<PayProveBO> getPayProveList() {
        return payProveList;
    }

    public void setPayProveList(List<PayProveBO> payProveList) {
        this.payProveList = payProveList;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getStrategyId() {
        return strategyId;
    }

    public void setStrategyId(Long strategyId) {
        this.strategyId = strategyId;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public Long getPayMemberId() {
        return payMemberId;
    }

    public void setPayMemberId(Long payMemberId) {
        this.payMemberId = payMemberId;
    }

    public Long getPayRoleId() {
        return payRoleId;
    }

    public void setPayRoleId(Long payRoleId) {
        this.payRoleId = payRoleId;
    }

    public String getSettlementNo() {
        return settlementNo;
    }

    public void setSettlementNo(String settlementNo) {
        this.settlementNo = settlementNo;
    }

    public Integer getSettlementWay() {
        return settlementWay;
    }

    public void setSettlementWay(Integer settlementWay) {
        this.settlementWay = settlementWay;
    }

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public Long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Long totalCount) {
        this.totalCount = totalCount;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Long getSettlementTime() {
        return settlementTime;
    }

    public void setSettlementTime(Long settlementTime) {
        this.settlementTime = settlementTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getPayWay() {
        return payWay;
    }

    public void setPayWay(Integer payWay) {
        this.payWay = payWay;
    }

    public Long getPrePayTime() {
        return prePayTime;
    }

    public void setPrePayTime(Long prePayTime) {
        this.prePayTime = prePayTime;
    }

    public Long getPayTime() {
        return payTime;
    }

    public void setPayTime(Long payTime) {
        this.payTime = payTime;
    }

    public Long getSettlementDate() {
        return settlementDate;
    }

    public void setSettlementDate(Long settlementDate) {
        this.settlementDate = settlementDate;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }
}
